import { defineStore } from 'pinia';
import { ref } from 'vue';



export const useUserStore = defineStore('user', () => {
    const userInfo = ref({})
    const isok = ref(false)
    const getUserInfo = () => {
        return userInfo
    }

    const clearUserInfo = () => {
        userInfo.value = {}
    }
    const isLogin = ()=> {
        return isok.value == true
    }
    const Login = ({ username, password }) => {
        userInfo.value = {
            username: username,
            password: password
        }
        isok.value = true
    }
    const Logout = () => {
        userInfo.value = {}
        isok.value = false
    }
    return {
        userInfo,
        getUserInfo,
        clearUserInfo,
        Login,
        Logout,
        isLogin,
        isok
    }
}, {
    persist: true,
},
)